<template>
  <el-table :data="tableData" style="width: 100%" ref="aa" > 
    <el-table-column label="Date" width="180" prop="date" sortable>
      <template #default="scope">
        <div style="display: flex; align-items: center">
          <el-icon>
            <timer />
          </el-icon>
          <span style="margin-left: 10px">{{ scope.row.date }}</span>
        </div>
      </template>
    </el-table-column>
    <el-table-column label="id" width="180" prop="id" sortable>

    </el-table-column>
    <el-table-column label="Name" width="180">
      <template #default="scope">
        <el-popover effect="light" trigger="hover" placement="top" width="auto">
          <template #default>
            <div>name: {{ scope.row.name }}</div>
            <div>address: {{ scope.row.address }}</div>
          </template>
          <template #reference>
            <el-tag>{{ scope.row.name }}</el-tag>
          </template>
        </el-popover>
      </template>
    </el-table-column>
    <el-table-column label="Operations">
      <template #default="scope">
        <el-button
          size="small"
          type="danger"
          @click="handleDelete(scope.$index, scope.row)"
        >
          查看详情
        </el-button>
        <!-- <el-popconfirm title="确认要删除吗？" @confirm="(e)=>queren(e,scope.row)">
          <template #reference>
            <el-button>删除</el-button>
          </template>
        </el-popconfirm> -->
      </template>
    </el-table-column>
  </el-table>
  <MydaiLog title="查看弹窗" v-model:upaa="dialogVisible" v-if="dialogVisible" :data="rowData"      :before-close="handelClose"></MydaiLog>
</template>

<script lang="ts" setup>
import { Timer } from '@element-plus/icons-vue'
import MydaiLog from "@/components/DeldaiLog.vue"
import { onMounted, ref, watch } from 'vue'
interface User {
  date: string
  name: string
  address: string
  id:number
}

const tableData: User[] = [
  {
    id:1,
    date: '2016-05-03',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    id:2,
    date: '2016-05-02',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    id:3,
    date: '2016-05-04',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    id:4,
    date: '2016-05-01',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
]
const dialogVisible=ref(false)
const rowData=ref("")
const aa=ref(null)
// 查看详情
const handleDelete=(idx,row)=>{
 console.log(idx,row)
 dialogVisible.value = true
 rowData.value=row
}
console.log("dialogVisible",dialogVisible.value)
watch(dialogVisible,()=>{
  console.log('dialogVisible',dialogVisible.value)
})
const handelClose=(done)=>{
  setTimeout(()=>{done()},1000)
}
onMounted(()=>{
  // aa.value.sort('id', 'descending')
  // console.log('aa.value',aa.value.sort)
})

</script>